import pygame
import sys
import time
#Iniciar pygame
pygame.init()

# Configurar la ventana
ancho = 1024
alto = 768
ventana = pygame.display.set_mode((ancho, alto))
pygame.display.set_caption('The power of effort.')

fondo = pygame.image.load("img/fondo.jpg") 
x,y = 0,0
ventana.blit(fondo, [x,y])
pygame.display.flip()

campeon = pygame.image.load("img/porfin.tga")
x2,y2 = 400, 400
ventana.blit(campeon, [x2,y2])
pygame.display.flip()

# Bucle de eventos
while True:
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			pygame.quit()
			sys.exit()
		if event.type == pygame.KEYDOWN:
			if event.key == pygame.K_LEFT:
				ventana.blit(fondo,[x,y])
				x2 = x2 - 10
				ventana.blit(campeon, [x2,y2])
				pygame.display.flip()
			if event.key == pygame.K_SPACE:
				ventana.blit(fondo,[x,y])
				y2 = y2 - 30
				ventana.blit(campeon, [x2,y2])
				pygame.display.flip()
				ventana.blit(fondo, [x,y])
				time.sleep(0.3)
				y2 = y2 + 30
				ventana.blit(campeon, [x2,y2])
				pygame.display.flip()
